package com.demo.swingquickticket.entity;

import lombok.Data;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Data
public class Station {

    //编号
    private int id;

    //站台中文名
    private String stationName;

    //站台code
    private String stationCode;

    //拼音缩写1
    private String subName1;

    //拼音缩写2
    private String subName2;

    //拼音全写
    private String fullName;

    @Override
    public String toString() {
        return stationName + "|" + stationCode + "|" + fullName;
    }

    public static List<String> toListString(List<Station> stationList) {
        List<String> result = new ArrayList<>();
        for (Station station : stationList) {
            result.add(station.toString());
        }
        return result;
    }

    public static Map<String, List<Station>> addStations(String stationStr) {
        Map<String, List<Station>> stationMap = new HashMap<>();
        stationMap.put("ABCDE", new ArrayList<>());
        stationMap.put("FGHIJ", new ArrayList<>());
        stationMap.put("KLMNO", new ArrayList<>());
        stationMap.put("PQRST", new ArrayList<>());
        stationMap.put("UVWXYZ", new ArrayList<>());

        List<Station> aList = new ArrayList<>();
        List<Station> bList = new ArrayList<>();
        List<Station> cList = new ArrayList<>();
        List<Station> dList = new ArrayList<>();
        List<Station> eList = new ArrayList<>();
        List<Station> fList = new ArrayList<>();
        List<Station> gList = new ArrayList<>();
        List<Station> hList = new ArrayList<>();
        List<Station> iList = new ArrayList<>();
        List<Station> jList = new ArrayList<>();
        List<Station> kList = new ArrayList<>();
        List<Station> lList = new ArrayList<>();
        List<Station> mList = new ArrayList<>();
        List<Station> nList = new ArrayList<>();
        List<Station> oList = new ArrayList<>();
        List<Station> pList = new ArrayList<>();
        List<Station> qList = new ArrayList<>();
        List<Station> rList = new ArrayList<>();
        List<Station> sList = new ArrayList<>();
        List<Station> tList = new ArrayList<>();
        List<Station> uList = new ArrayList<>();
        List<Station> vList = new ArrayList<>();
        List<Station> wList = new ArrayList<>();
        List<Station> xList = new ArrayList<>();
        List<Station> yList = new ArrayList<>();
        List<Station> zList = new ArrayList<>();

        String[] str = stationStr.split("@");
        for (String temp : str) {
            String[] data = temp.split("\\|");
            Station station = new Station();
            station.setSubName1(data[0]);
            station.setStationName(data[1]);
            station.setStationCode(data[2]);
            station.setFullName(data[3]);
            station.setSubName2(data[4]);
            station.setId(Integer.parseInt(data[5]));

            switch (station.getFullName().substring(0,1)) {
                case "a": aList.add(station); break;
                case "b": bList.add(station); break;
                case "c": cList.add(station); break;
                case "d": dList.add(station); break;
                case "e": eList.add(station); break;
                case "f": fList.add(station); break;
                case "g": gList.add(station); break;
                case "h": hList.add(station); break;
                case "i": iList.add(station); break;
                case "j": jList.add(station); break;
                case "k": kList.add(station); break;
                case "l": lList.add(station); break;
                case "m": mList.add(station); break;
                case "n": nList.add(station); break;
                case "o": oList.add(station); break;
                case "p": pList.add(station); break;
                case "q": qList.add(station); break;
                case "r": rList.add(station); break;
                case "s": sList.add(station); break;
                case "t": tList.add(station); break;
                case "u": uList.add(station); break;
                case "v": vList.add(station); break;
                case "w": wList.add(station); break;
                case "x": xList.add(station); break;
                case "y": yList.add(station); break;
                case "z": zList.add(station); break;
                default: break;
            }
        }
        stationMap.get("ABCDE").addAll(aList);
        stationMap.get("ABCDE").addAll(bList);
        stationMap.get("ABCDE").addAll(cList);
        stationMap.get("ABCDE").addAll(dList);
        stationMap.get("ABCDE").addAll(eList);

        stationMap.get("FGHIJ").addAll(fList);
        stationMap.get("FGHIJ").addAll(gList);
        stationMap.get("FGHIJ").addAll(hList);
        stationMap.get("FGHIJ").addAll(iList);
        stationMap.get("FGHIJ").addAll(jList);

        stationMap.get("KLMNO").addAll(kList);
        stationMap.get("KLMNO").addAll(lList);
        stationMap.get("KLMNO").addAll(mList);
        stationMap.get("KLMNO").addAll(nList);
        stationMap.get("KLMNO").addAll(oList);

        stationMap.get("PQRST").addAll(pList);
        stationMap.get("PQRST").addAll(qList);
        stationMap.get("PQRST").addAll(rList);
        stationMap.get("PQRST").addAll(sList);
        stationMap.get("PQRST").addAll(tList);

        stationMap.get("UVWXYZ").addAll(uList);
        stationMap.get("UVWXYZ").addAll(vList);
        stationMap.get("UVWXYZ").addAll(wList);
        stationMap.get("UVWXYZ").addAll(xList);
        stationMap.get("UVWXYZ").addAll(yList);
        stationMap.get("UVWXYZ").addAll(zList);

        return stationMap;
    }


}
